package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.IntegralDetailMapper;
import com.gc.business.domain.IntegralDetail;
import com.gc.business.service.IIntegralDetailService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 积分明细 服务层实现
 * 
 * @author liujinteng
 * @date 2021-01-04
 */
@Slf4j
@Service
public class IntegralDetailServiceImpl extends ServiceImpl<IntegralDetailMapper, IntegralDetail> implements IIntegralDetailService {

    @Override
    public List<IntegralDetail> list(IntegralDetail integralDetail){
        LambdaQueryWrapper<IntegralDetail> wrapper = new LambdaQueryWrapper<>();
        if(integralDetail != null){
            if(StringUtils.isNotEmpty(integralDetail.getDetailId())){
                wrapper.eq(IntegralDetail::getDetailId, integralDetail.getDetailId());
            }
            if(StringUtils.isNotEmpty(integralDetail.getDetailTitle())){
                wrapper.eq(IntegralDetail::getDetailTitle, integralDetail.getDetailTitle());
            }
            if(StringUtils.isNotEmpty(integralDetail.getChangeScore())){
                wrapper.eq(IntegralDetail::getChangeScore, integralDetail.getChangeScore());
            }
            if(StringUtils.isNotEmpty(integralDetail.getUserId())){
                wrapper.eq(IntegralDetail::getUserId, integralDetail.getUserId());
            }
            if(StringUtils.isNotEmpty(integralDetail.getCreateBy())){
                wrapper.eq(IntegralDetail::getCreateBy, integralDetail.getCreateBy());
            }
            if(StringUtils.isNotEmpty(integralDetail.getCreateTime())){
                wrapper.eq(IntegralDetail::getCreateTime, integralDetail.getCreateTime());
            }
            if(StringUtils.isNotEmpty(integralDetail.getUpdateBy())){
                wrapper.eq(IntegralDetail::getUpdateBy, integralDetail.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(integralDetail.getUpdateTime())){
                wrapper.eq(IntegralDetail::getUpdateTime, integralDetail.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(integralDetail.getRemark())){
                wrapper.eq(IntegralDetail::getRemark, integralDetail.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    /**
     * 查询指定月份下的积分
     * @param yearMonth
     * @param userId
     * @return
     */
    @Override
    public Integer selectScoreByMonth(String yearMonth, Long userId) {
        return baseMapper.selectScoreByMonth(yearMonth,userId);
    }
}
